package com.mycompany.lctwitter.persist.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.mycompany.lctwitter.persist.dao.UserDao;
import com.mycompany.lctwitter.persist.model.User;

@Service("userService")
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public class UserService {
    @Resource
    private UserDao userDao;

    public User login(String userName, String pwd) {
        return userDao.login(userName, pwd);
    }

    @Transactional
    public User add(String userName, String pwd) {
        return userDao.add(userName, pwd);
    }

    public User find(long userId) {
        return userDao.get(userId);
    }

    public User find(String userName) {
        return userDao.find(userName);
    }

}
